import axios from "./request";

export const refreshToken = () => {
    let r_tk = sessionStorage.getItem("refreshtoken") //获取长token
    if (r_tk) {
        console.log(r_tk);
        axios.get("/refresh", Object.assign({}, {
            Headers: { refreshToken: r_tk } //设置请求头
        }).then((res) => {
            if (res.data.code === 401) {
                sessionStorage.removeItem("refreshtoken")
            } else if (res.data.code === 200) {
                sessionStorage.setItem('accesstoken', res.data.accessToken)
                sessionStorage.setItem('refreshtoken', res.data.refreshToken)
            }
        }))
    }
}